using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using IGlobalist.Cms.Model;

namespace IGlobalist.Cms.Common
{
    public class MainProperty
    { 
        private static XmlDocument xDoc;
        static MainProperty()
        {
            xDoc = new XmlDocument();
            string path = HttpContext.Current.Request.PhysicalApplicationPath;
            xDoc.Load(path + "Admin/XML/MainProperty.xml");
        }

        public static PropertyList GetPropertyList(short classTypeID)
        {
            PropertyList list=new PropertyList();
            string xpath = String.Format("//classtype[@ID='{0}']", classTypeID);
            XmlNodeList xNodeList=xDoc.DocumentElement.SelectSingleNode(xpath).ChildNodes;
            foreach (XmlNode node in xNodeList)
            {
                BaseProperty property = new BaseProperty();
                property.Name = node.Attributes["Name"].Value;
                property.DisplayName = node.Attributes["DisplayName"].Value;
                property.Description = node.Attributes["Description"].Value;
                property.Value = node.Attributes["Value"].Value;
                property.Type =(DataType)Enum.Parse(typeof(DataType), node.Attributes["Type"].Value);
                property.InputType = (InputType)Enum.Parse(typeof(InputType), node.Attributes["InputType"].Value);
                property.PropertyType = PropertyType.Main;
                list.Add(property);
            }
            return list;
        }
    }
}
